package main

import "fmt"
func testForRange() {
    var s string = "abcdefg"

    for index, value := range s {
        println("index: ", index, "code: ", value, "value: ", string(value))
    }
    fmt.Println()

    var arr [5]int = [5]int{1, 2, 3, 4, 5}
    for index, value := range arr {
        println("index: ", index, "value: ", value)
    }
    fmt.Println()

    var slice []int = []int{1, 2, 3, 4, 5}
    slice = append(slice, 6)
    for index, value := range slice {
        println("index: ", index, "value: ", value)
    }
    fmt.Println()

   var m1 map[string]any = map[string]any{
        "name": "zs",
        "gender": "male",
        "age": 28,
    }
    for key, value := range m1 {
        fmt.Println("key: ", key, "value: ", value)
    }
    fmt.Println()

    var m2 map[string]interface{} = make(map[string]interface{}, 4);
    m2["name"] = "ls";
    m2[ "gender"] = "female";
    m2["age"] = 40;
    m2["school"] = "清华大学"
    m2["hobby"] = "足球，篮球"

    for key, value := range m2 {
        fmt.Println("key: ", key, "value: ", value)
    }
}

func main() {
	testForRange()
}